from flask import Flask,render_template
import sqlite3
import datetime
app = Flask(__name__)


@app.route('/')
def hello_world():
    return render_template("index.html")

'''
def movie():
    datalist  = []
    con = sqlite3.connect("movie.db")
    cur = con.cursor()
    sql = "select * from movie250"
    data = cur.execute(sql)
    for item in data:
        datalist.append(item)
    cur.close()
    con.close()
    print(datalist)
    return render_template("movie.html",movies = datalist)
'''
@app.route("/movie")
def movie():
    datalist  = []
    con = sqlite3.connect("豆瓣电影Top250_data.db")
    cur = con.cursor()
    sql = "select * from movie_T250"
    data = cur.execute(sql)
    for item in data:
        datalist.append(item)
    cur.close()
    con.close()
    print(datalist)
    return render_template("movie.html",movies = datalist)

@app.route('/score')
def score():
    x_score =[]#分数种类
    y_count =[]#统计
    con = sqlite3.connect("豆瓣电影Top250_data.db")
    cur = con.cursor()
    sql = "select score,count(score) from movie_T250 group by score"
    data = cur.execute(sql)
    for item in data:
        x_score.append(item[0])
        y_count.append(item[1])
    cur.close()
    con.close()
    date = datetime.date.today()
    return render_template("score.html",x_score=x_score,y_count=y_count,date = date)

@app.route('/word')
def word():
    return render_template("word.html")

@app.route('/team')
def team():
    return render_template("team.html")



if __name__ == '__main__':
    app.run()
